package com.jd.cs.error;

import java.util.Arrays;

/**
 * @author: lizhiwei
 * @date: 2020-07-25 23:18
 **/
public enum ErrorCode {
    /**
     * 注释参见desc字段
     */
    SUCCESS("10000", "成功"),
    FAIL("10001", "失败"),
    PARAMETER_ERROR("10002", "参数错误"),
    HEADER_PARAMETER_ERROR("10003", "头参数错误"),


    E_20000("20000", "token为空"),
    E_20001("20001", "签名错误"),
    ;
    String code;
    String msg;

    ErrorCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static ErrorCode getByCode(String value) {
        return Arrays.stream(values()).filter(v -> v.getCode().equals(value)).findFirst().orElse(null);
    }

}